package com.intretech.umsin.oss.config;

import com.intretech.umsin.oss.util.ftppool.FtpClientFactory;
import com.intretech.umsin.oss.util.ftppool.FtpClientPool;
import com.intretech.umsin.oss.util.ftppool.FtpClientTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @version V1.0
 * @ClassName: FtpOSSConfig
 * @Description: FtpOSSConfig 服务实现
 * @author: 李启联
 * @date: 2022-04-25 22:23
 * @Copyright: Copyright (c) 2022
 */
@Configuration
@ConditionalOnProperty(name = "oss-type",havingValue = "FTP",matchIfMissing = false)
public class FtpOSSConfig {

    @Autowired
    private FtpClientProperties ftpClientProperties;


    @Bean
    public FtpClientFactory fpClientFactory() {
        return new FtpClientFactory(ftpClientProperties);
    }

    @Bean
    public FtpClientPool ftpClientPool(FtpClientFactory fpClientFactory){
        return  new FtpClientPool(fpClientFactory);
    }

    @Bean
    public FtpClientTemplate ftpClientTemplate(FtpClientPool fFtpClientPool) {
        return new FtpClientTemplate(fFtpClientPool);
    }

}
